<template>
	<div>
		<div class="h2">积分申请审批</div>
		<a-tabs default-active-key="3" @change="tabChange">
		      <a-tab-pane key="3" tab="学校待审批">
		        <div id="components-form-demo-advanced-search">
		        	<a-form class="ant-advanced-search-form home-form" :form="form" @submit="handleSearch2">
		        		<a-row :gutter="24">
		        			<a-col :span="8">
		        				<a-form-item label="标题"><a-input autocomplete="off" class="field-right" placeholder="请输入标题搜索" v-decorator="[`key`]" /></a-form-item>
		        			</a-col>
		        			<a-col :span="8" style="margin-top:4px;">
		        				<a-button type="primary" html-type="submit" class="btn1">搜索</a-button>
		        				<a-button :style="{ marginLeft: '8px' }" @click="handleReset2" class="btn2">重置</a-button>
		        			</a-col>
		        		</a-row>
		        	</a-form>
		        </div>
		        <div>
		        	<el-table :data="data2" v-loading="loading2" border :max-height="tableHeight" highlight-current-row style="width: 100%;">
		        		<el-table-column prop="ActivityTitle" label="标题" min-width="130" fixed="left"></el-table-column>
		        		<el-table-column prop="AddTime" label="时间" min-width="200"></el-table-column>
								<el-table-column prop="AddUserNo" label="申请人" min-width="160">
									<template slot-scope="scope">
										<a-tag color="blue">{{ scope.row.AddUserNo }}</a-tag>
										{{ scope.row.AddUserName }}
									</template>
								</el-table-column>
		        		<el-table-column prop="ChargeUserNo" label="审批节点" min-width="160">
		        			<template slot-scope="scope">
		        				<a-tag color="blue">{{ scope.row.FlowTypeName }}</a-tag>
		        			</template>
		        		</el-table-column>
		        		<el-table-column label="操作" width="120" fixed="right">
		        			<template slot-scope="scope">
		        				<i title="详情" class="iconfont icon-xiangqing" style="color: #1890FF;" @click="seeList(scope.row, 'detail')"></i>
		        				<i title="审批" class="iconfont icon-shenpi" style="color: red;" @click="applyHander(scope.row)"></i>
		        			</template>
		        		</el-table-column>
		        	</el-table>
		        	<el-pagination
		        		@size-change="handleSizeChange2"
		        		@current-change="handleCurrentChange2"
		        		:current-page="pagination2.currentPage"
		        		:page-sizes="pagination2.pageSizeOptions"
		        		:page-size="pagination2.pageSize"
		        		layout="total, sizes, prev, pager, next, jumper"
		        		:total="pagination2.total"
		        	></el-pagination>
		        </div>
		      </a-tab-pane>
					<a-tab-pane key="4" tab="学校已审批">
					  <div id="components-form-demo-advanced-search">
					  	<a-form class="ant-advanced-search-form home-form" :form="form" @submit="handleSearch3">
					  		<a-row :gutter="24">
					  			<a-col :span="8">
					  				<a-form-item label="关键字"><a-input autocomplete="off" class="field-right" placeholder="请输入关键字搜索" v-decorator="[`key`]" /></a-form-item>
					  			</a-col>
					  			<a-col :span="8" style="margin-top:4px;">
					  				<a-button type="primary" html-type="submit" class="btn1">搜索</a-button>
					  				<a-button :style="{ marginLeft: '8px' }" @click="handleReset3" class="btn2">重置</a-button>
					  			</a-col>
					  		</a-row>
					  	</a-form>
					  </div>
					  <div>
					  	<el-table :data="data3" v-loading="loading3" border :max-height="tableHeight" highlight-current-row style="width: 100%;">
					  		<el-table-column prop="ActivityTitle" label="标题" min-width="130" fixed="left"></el-table-column>
					  		<el-table-column prop="AddTime" label="时间" min-width="200"></el-table-column>
								<el-table-column prop="AddUserNo" label="申请人" min-width="160">
									<template slot-scope="scope">
										<a-tag color="blue">{{ scope.row.AddUserNo }}</a-tag>
										{{ scope.row.AddUserName }}
									</template>
								</el-table-column>
					  		<el-table-column prop="ChargeUserNo" label="审批节点" min-width="160">
					  			<template slot-scope="scope">
					  				<a-tag color="blue">{{ scope.row.FlowTypeName }}</a-tag>
					  			</template>
					  		</el-table-column>
					  		<el-table-column label="操作" width="120" fixed="right">
					  			<template slot-scope="scope">
					  				<i title="详情" class="iconfont icon-xiangqing" style="color: #1890FF;" @click="seeList(scope.row, 'detail',2)"></i>
					  			</template>
					  		</el-table-column>
					  	</el-table>
					  	<el-pagination
					  		@size-change="handleSizeChange3"
					  		@current-change="handleCurrentChange3"
					  		:current-page="pagination3.currentPage"
					  		:page-sizes="pagination3.pageSizeOptions"
					  		:page-size="pagination3.pageSize"
					  		layout="total, sizes, prev, pager, next, jumper"
					  		:total="pagination3.total"
					  	></el-pagination>
					  </div>
					</a-tab-pane>
		    </a-tabs>
		
		<apply :text="text" v-show="applyIf" @closeFun="closeFun"></apply>
	</div>
</template>

<script>
	import moment from 'moment';
import apply from './apply';
import Func from '@/utils/func';
import { GetUserApplyItemFlowSchoolExamPageList,GetUserApplyItemFlowSchoolAlreadyExamPageList, DeleteActivity,GetActivityStateList,GetClubPageListCommon } from '@/api/follow';
const data2 = [];
const data3 = [];
export default {
	components: {
		apply
	},
	data() {
		return {
			applyIf:false,
			data2,
			data3,
			form: this.$form.createForm(this, {
				name: 'advanced_search'
			}),
			pagination2: {
				currentPage: 1,
				pageSize: this.global.pageSize,
				pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
				showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
			},
			pagination3: {
				currentPage: 1,
				pageSize: this.global.pageSize,
				pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
				showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
			},
			addIf: false,
			text: {},
			visible: false,
			confirmLoading: false,
			itemId: '',
			departmentList: [],
			worklist: [],
			loading2: false,
			loading3: false,
			values2: {},
			values3: {},
			tableHeight: parseFloat(window.innerHeight - 160),
			ActivityStateList:[],
			ClubList:[],
			tabkey:3
		};
	},
	computed: {},
	created() {
		this.getList2();
		this.getList3();
		this.getOtherList()
	},
	mounted() {},
	methods: {
		moment,
		tabChange(key) {
			this.tabkey = key
    },
		filterOption(input, option) {
			return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
		},
		async fetchClub(value) {
			let myReg = /^[^a-zA-Z]+$/;
			if (value && value.length>1) {
				let data = {};
				data.key = value;
				let res = await GetClubPageListCommon(data);
				this.ClubList = res.data.data
			}
		},
		handleSearch2(e) {
			e.preventDefault();
			this.form.validateFields((error, values) => {
				this.pagination2.currentPage = 1;
				this.values2 = values;
				this.getList2();
			});
		},
		handleSearch3(e) {
			e.preventDefault();
			this.form.validateFields((error, values) => {
				this.pagination3.currentPage = 1;
				this.values3 = values;
				this.getList3();
			});
		},
		handleReset2() {
			this.form.resetFields();
			this.values2 = {};
			this.getList2();
		},
		handleReset3() {
			this.form.resetFields();
			this.values3 = {};
			this.getList3();
		},
		handleSizeChange2(val) {
			this.pagination.pageSize = val;
			this.getList();
		},
		handleCurrentChange2(val) {
			this.pagination.currentPage = val;
			this.getList();
		},
		handleSizeChange3(val) {
			this.pagination.pageSize = val;
			this.getList();
		},
		handleCurrentChange3(val) {
			this.pagination.currentPage = val;
			this.getList();
		},
		async getList2() {
			this.loading2 = true;
			let data = {};
			if (this.values2) {
				data = this.values2;
			}
			data.pageIndex = this.pagination2.currentPage;
			data.pageSize = this.pagination2.pageSize;
			let res = await GetUserApplyItemFlowSchoolExamPageList(data);
			this.loading2 = false;
			this.data2 = res.data.data;
			const pagination = { ...this.pagination2 };
			pagination.total = res.data.pageInfo.TotalItemCount;
			this.pagination2 = pagination;
		},
		async getList3() {
			this.loading3 = true;
			let data = {};
			if (this.values3) {
				data = this.values3;
			}
			data.pageIndex = this.pagination3.currentPage;
			data.pageSize = this.pagination3.pageSize;
			let res = await GetUserApplyItemFlowSchoolAlreadyExamPageList(data);
			this.loading3 = false;
			this.data3 = res.data.data;
			const pagination = { ...this.pagination3 };
			pagination.total = res.data.pageInfo.TotalItemCount;
			this.pagination3 = pagination;
		},
		async getOtherList(){
			let res = await GetActivityStateList()
			this.ActivityStateList = res.data.data
			let res1 = await GetClubPageListCommon(data);
			this.ClubList = res1.data.data
		},
		addList() {
			this.text = {};
			this.addIf = !this.addIf;
		},
		seeList(text,name,type){
			let path = 'UserApplyItemFlowDetail'
			this.$router.push({
				name: path,
				query: {
					ID: text.ID,
					type: type
				}
			});
		},
		applyHander(item){
			this.text = item
			this.applyIf = true
		},
		closeFun() {
			this.applyIf = false;
			if(this.tabkey==3){
				this.getList2()
			}
			if(this.tabkey==4){
				this.getList3()
			}
			
		}
	}
};
</script>

<style lang="less" scoped>
/deep/.ant-form-item {
	display: flex;
	margin-bottom: 10px !important;

	/deep/.ant-form-item-label {
		width: 80px;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		text-align: right;
	}
	/deep/.ant-form-item-control-wrapper {
		flex: 1;
	}
}
/deep/.el-table th.is-leaf {
	background: #fafafa;
}
/deep/.el-table td,
/deep/.el-table th {
	padding: 5px;
}
.option {
	margin-top: 10px;
	margin-bottom: 20px;
	overflow: hidden;
}
.option .btn {
	height: 36px;
	line-height: 36px;
	padding: 0 10px;
	float: left;
	background: #1890ff;
	color: #fff;
	margin-right: 10px;
	border-radius: 3px;
	cursor: pointer;
	border: none;
}
.foot {
	text-align: center;
	margin-top: 100px;
}
.el-pagination {
	margin-top: 10px;
}
</style>
